**************************************************************************************
* Social context by age
**************************************************************************************

use  "Data_temp/turnout.dta", clear
keep if inrange(age,16,26.5)

// children with parents in household: as proxy for living with parents
gen children_hh=(inlist(hhtype,4,5,6,7)) if hhtype<.
replace children_hh=0 if lprnt==1 // replace to 0 if they are natural parents of a child

gen age_int=int(age)
tab age_int, sum(still_school)
tab age_int, sum(in_education)
 
gen age_half=.
forvalues x = 16/26 {
	replace age_half=`x'.25 if inrange(age,`x',`x'.4)
	replace age_half=`x'.75 if inrange(age,`x'.5,`x'.9)
	}
 

 
 

collapse single employed married hhsize in_education children_hh, by(age_half)

sort age
	
twoway 	(scatter  single married employed  children in_education age, ///
		msymbol(D O + S T) mfcolor(white white white white white) ///
		mlwidth(medthick medthick medthick medthick medthick) ///
		mlcolor(black edkblue edkblue edkblue dknavy)) ///
		(scatter hhsize age, yaxis(2) msymbol(X) mcolor(dknavy) mfcolor(white) ///
		mlwidth(medthick)), ///
		xt("Age") yt("Share") legend(order(4 "Living with parents" 1 "Single" ///
		2 "Married or cohabiting" ///
		5 "In education - school or higher education" 3 "Employed" 6   "Household size (right axis)") ///
		size(*1) row(2)) ///
		xlab(16(1)26) yt("Household size", axis(2)) ylab(0(1)5, axis(2))

graph export "Figures/a_fg13.eps", replace
